package com.ysd.zhaoxing.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ysd.zhaoxing.dao.IStudentsDao;
import com.ysd.zhaoxing.dto.StudentsDTO;
import com.ysd.zhaoxing.model.Students;

@RequestMapping("students")
@RestController
public class StudentsController {
	@Resource
	private IStudentsDao studentsDao;
	
	/**多条件分页查询
	 * @param dto
	 * @return
	 */
	@RequestMapping("findAll")
	public Map findAll(StudentsDTO dto) {
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("code", 0);
		map.put("count", studentsDao.getCount(dto));
		map.put("data", studentsDao.findAll(dto));
		return map;
	}
	/**编辑
	 * @param s
	 * @return
	 */
	@RequestMapping("edit")
	public String edit(Students s) {
		studentsDao.edit(s);
		return "success";
	}
	
	/**添加
	 * @param s
	 * @return
	 */
	@RequestMapping("add")
	public String add(Students s) {
		studentsDao.add(s);
		return "success";
	}
}
